package com.zhf.springboot.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: 曾鸿发
 * @create: 2022-01-10 23:30
 * @description：
 **/
@Configuration
public class TopicConfig {

    @Bean
    public Queue topicQ1(){
        return new Queue("topic_sb_mq_q1");
    }

    @Bean
    public Queue topicQ2(){
        return new Queue("topic_sb_mq_q2");
    }

    @Bean
    public TopicExchange setTopicExchange(){
        return new TopicExchange("topicExchange");
    }

    @Bean
    public Binding bindTopicHebei1(){
        return BindingBuilder.bind(topicQ1()).to(setTopicExchange()).with("changsha.*");
    }

    public Binding bindTopicHenan1(){
        return BindingBuilder.bind(topicQ2()).to(setTopicExchange()).with("#.beijing");
    }
}
